package cate.game.play.buff.h;

import cate.game.play.buff.BuffHandler;
import cate.game.play.config.PlayCfgArgs;
import cate.game.play.fighter.Fighter;
import cate.game.play.proce.action.ctx.ActionCtx;

/**
 * 叠加到2层后爆炸对携带者一方全体单位造成施法者31%攻击的法术伤害
 */
public class 饱腹BH extends BuffHandler {

	private int 层数;

	private double 伤害系数;

	//层数=2&伤害系数=3100
	@Override
	public void parse(String code) {
		PlayCfgArgs args = new PlayCfgArgs(code);
		层数 = args.getInt("层数", 0);
		伤害系数 = args.getWDouble("伤害系数", 0d);
	}

	@Override
	public void onAdd(ActionCtx action) {
		int curNum = buff.owner.buff.countBuffByTid(buff.tid);
		if (curNum <= 层数 - 1) {
			return;
		}
		double damage = buff.caster.attr.attTotal()*伤害系数;
		for (Fighter target : buff.owner.getFightTeam().getFightersAlive()) {
			target.attr.buffHurt(action, buff.caster, damage);
		}
		buff.owner.buff.removeBuffByTid(action, buff.tid);
	}
}
